package io.renren.common.constants.enums;

import com.alibaba.fastjson.annotation.JSONType;
import io.renren.common.utils.json.EnumValueDeserializer;
import lombok.Getter;

import java.util.Arrays;

/**
 * 匹配模式枚举
 */
@Getter
@JSONType(deserializer = EnumValueDeserializer.class)
public enum MatchType implements EnumValue{
    INTELLIGENT(1,"智能"),
    CUSTOMIZE(2,"定制"),
    ;

    /**值*/
    private int value;
    /**描述*/
    private String desc;

    MatchType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    /**
     * 获取枚举
     *
     * @return
     */
    public static MatchType getByCode(int code) {
        return Arrays.stream(values()).filter(e -> e.getValue() == code).findFirst().orElse(INTELLIGENT);
    }

    @Override
    public int value() {
        return this.value;
    }
}
